package com.company.framework.common.exception;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 业务异常
 *
 * @author zhushangyi
 */
@Slf4j
@Getter
public class CpmException extends RuntimeException {

    /**
     * 错误码
     */
    private int code;

    /**
     * 错误信息
     */
    private String message;

    private String format;

    public CpmException(){

    }

    public CpmException(String message){
        this.message = message;
    }

    public CpmException(String message, int code){
        this.message = message;
        this.format = message;
        this.code = code;
    }

    public CpmException formatMessage(Object... args){
        log.info("PRINT_LOG:{}",args);
        if(args.length > 0){
            this.message = String.format(this.format,args);
        }
        return this;
    }
}
